package cc.yugu.yhdw.webserver.web.controller.security.basic;

import cc.yugu.yhdw.common.annotation.ViewModel;
import cc.yugu.yhdw.common.domain.basic.CustomerDepositGift;
import cc.yugu.yhdw.common.entity.json.ExtResult;
import cc.yugu.yhdw.webserver.constant.AppConstEnum;
import cc.yugu.yhdw.webserver.service.basic.CustomerDepositGiftService;
import cc.yugu.yhdw.webserver.web.controller.security.SecurityController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.List;
/**
 * 充值优惠控制器
 * 
 * @Date:Created in 2018/7/17 13:36
 * @Author:
 * @Modified By: zjn 2018/7/17 13:36
 */ 
@Controller
@RequestMapping(value = "/security/basic/customer_deposit_gift")
public class CustomerDepositGiftController extends SecurityController {

    @Autowired
    CustomerDepositGiftService customerDepositGiftService;
    /**
    * 返回到index.ftl，前台显示用户充值信息
    * 
    * @Param: [model]
    * @Return: void
    * @Author By: zjn 2018/7/17  13:36
    */ 
    @RequestMapping(value = "index.htm")
    public void index(Model model) {
        // 查询优惠信息
        List<CustomerDepositGift> customerDepositGiftList =  customerDepositGiftService.findAll();

        model.addAttribute("customerGiftList", customerDepositGiftList);
        model.addAttribute(MENU_CODE_NAME, AppConstEnum.Menu.MENU_03_05.getValue());
    }
    /**
    * 更新 用户充值优惠信息
    * 
    * @Param: [money, gift]
    * @Return: cc.yugu.yhdw.common.entity.json.ExtResult
    * @Author By: zjn 2018/7/17  13:45
    */ 
    @RequestMapping("update.htm")
    @ViewModel(ViewModel.JSON)
    @ResponseBody
    public ExtResult update(double[] money, float[] gift) {
        customerDepositGiftService.update(money, gift);
        return ExtResult.successResult();
    }
}
